package com.yzc.role;

import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
@RequiredArgsConstructor
public class RoleService {
    final RoleDao roleDao;

//    public Map login(String name) {
//        return roleDao.login(name);
//    }

    public List loadaAll()  {
        //操作
       return  roleDao.loadaAll();
    }

    public Map updateInfo(RoleBean roleBean) {
        return roleDao.updateInfo(roleBean);
    }

    public Map save(RoleBean roleBean) {
        return roleDao.save(roleBean);
    }

    public List selectInfos(RoleBean roleBean) {
        return roleDao.selectInfos(roleBean);
    }

    public Map getInfoById(RoleBean roleBean) {
        return roleDao.getInfoById(roleBean);
    }

    public Map deleteInfo(RoleBean roleBean) {
        return roleDao.deleteInfo(roleBean);
    }

    public Map saveMenu(RoleBean roleBean){
        Map map = new HashMap();
        try {
            roleDao.deleteMenus(roleBean);
            roleDao.saveMenus(roleBean);
        map.put("result","success");
        } catch (Exception e) {
        map.put("result","error");
            throw new RuntimeException(e);
        }
        return map;
    }

    public List loadRoleList(){
        return roleDao.loadRoleList();
    }
}
